{% extends "socialaccount/base.html" %}
{% load i18n socialaccount staticfiles %}

{% block head_title %}{% trans "Account Connections" %}{% endblock %}

{% block content %}

<section class="box-section">
<h3>{% trans "Account Connections" %}</h3>
<div class="inner">

{% if form.accounts %}
	<p>
		The following social accounts are linked to your HSReplay.net account.
		You may log in with any of them.
	</p>
	<table id="account-connections">
		{% for base_account in form.accounts %}
			{% with base_account.get_provider_account as account %}
			<tr>
				<th>
					{% if account.get_brand.id == "battlenet" %}
						<img src="{% static 'images/bnet.png' %}"/>
					{% else %}
						<span class="socialaccount_provider {{ base_account.provider }} {{ account.get_brand.id }}">{{account.get_brand.name}}</span>
					{% endif %}
					{{ account }}
				</th>
				<td>
					<form action="{% url 'socialaccount_connections' %}" method="POST">
						{% csrf_token %}
						<input type="hidden" name="account" value="{{ base_account.id }}"/>
						<input type="submit" value="Remove"/>
					</form>
				</td>
				<td>
					{% if base_account.extra_data.battletag != request.user.username %}
					<form action="{% url 'account_make_primary' %}" method="POST">
						{% csrf_token %}
						<input type="hidden" name="account" value="{{ base_account.id }}"/>
						<input type="submit" value="Make primary"/>
					</form>
					{% else %}
						&#10004; Primary account
					{% endif %}
				</td>
			</tr>
			{% endwith %}
		{% endfor %}
	</table>
{% else %}
	<p>{% trans "You currently have no social network accounts connected to this account." %}</p>
{% endif %}
</div>
</section>

<section id="account-social-link" class="box-section">
<h3>Link a Battle.net account</h3>
<div class="inner">
	<p>
		Here, you can connect multiple Battle.net accounts to your HSReplay account.
	</p>

	<p class="alert alert-warning">
		NOTE: Make sure to <a href="https://battle.net/en/?logout" target="_blank">sign out of Battle.net</a>
		before connecting another account.
	</p>

	{% get_providers as socialaccount_providers %}
	<p>
		<a class="socialaccount_provider {{provider.id}} btn btn-primary" href="{% provider_login_url "battlenet" process="connect" %}">
			Connect a Battle.net account
		</a>
	</p>
</div>
</section>

{% include "socialaccount/snippets/login_extra.html" %}

{% endblock %}
